package com.sanyang.lawyer.controller.Statistics;

import com.sanyang.lawyer.service.finance.Finance_incomeService;
import com.sanyang.lawyer.service.finance.Finance_invoiceService;
import com.sanyang.lawyer.service.finance.Finance_payoutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: lawyer
 * @description: 财务统计控制层
 * @author: Mis.Feng
 * @create: 2019-10-28 15:12
 **/
@RestController
@RequestMapping("finStatistics")
public class FinancialStatisticsController<Finance_inv> {
    @Autowired
    private Finance_payoutService finance_payoutService;
    @Autowired
    private Finance_incomeService finance_incomeService;
    @Autowired
    private Finance_invoiceService finance_invoiceService;

    @RequestMapping("Statistics")
    public List<Map<String, Object>> statistics(HttpServletRequest request) {
        Map<String, Object> map = initMap(request);
        return finance_payoutService.Statistics(map);
    }

    public Map<String, Object> initMap(HttpServletRequest request) {
        String time = request.getParameter("time");
        String time3 = request.getParameter("time3");
        String empId=request.getParameter("empId");
        String empName=request.getParameter("empName");
        String starttime=request.getParameter("starttime");
        String endtime=request.getParameter("endtime");
        String payId=request.getParameter("payId");
        Map<String, Object> map = new HashMap();
        map.put("time", time);
        map.put("time3", time3);
        map.put("empId",empId);
        map.put("empName",empName);
        map.put("starttime",starttime);
        map.put("endtime",endtime);
        map.put("payId",payId);
        return map;
    }

   @RequestMapping("finaceIncome")
    public Map<String, Object> finaceIncome(HttpServletRequest request) {
       Map map = initMap(request);
       List<Map<String, Object>> list = finance_incomeService.selectByEmp(map);
       Integer i = list.size();
       map.put("code", 0);
       map.put("msg", "");
       map.put("count", i);
       map.put("data", list);
       return map;
    }

    @RequestMapping("historicalStatistics")
    public Map<String, Object> historicalStatistics(HttpServletRequest request) {
        Map map = initMap(request);
        System.out.println(map);
        List<Map<String, Object>> list = finance_incomeService.selecthistoricalStatistics(map);
        Integer i = list.size();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", i);
        map.put("data", list);
        return map;
    }

    @RequestMapping("cashierStatistics")
    public Map<String, Object> cashierStatistics(HttpServletRequest request) {
        Map map = initMap(request);
        System.out.println(map);
        List<Map<String, Object>> list = finance_payoutService.cashierStatistics(map);
        Integer i = list.size();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", i);
        map.put("data", list);
        return map;
    }
    //分类开票汇总
    @RequestMapping("invoiceCollect")
    public Map<String, Object> invoiceCollect(HttpServletRequest request) {
        Map map = initMap(request);
        System.out.println(map);
        List<Map<String, Object>> list = finance_invoiceService.invoiceCollect(map);
        Integer i = list.size();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", i);
        map.put("data", list);
        return map;
    }
}
